package cn.ac.sec.interceptor;

import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;
import org.springframework.web.servlet.config.annotation.InterceptorRegistration;
import org.springframework.web.servlet.config.annotation.InterceptorRegistry;
import org.springframework.web.servlet.config.annotation.WebMvcConfigurer;

@Configuration
public class WebSecurityConfig implements WebMvcConfigurer {
//extends WebMvcConfigurationSupport { 			//后期要集成swagger，继承WebMvcConfigurationSupport会出现加载不了swagger的静态文件问题

	@Bean
    public LoginInterceptor getLoginInterceptor() {
        return new LoginInterceptor();
    }
    
	public void addInterceptors(InterceptorRegistry registry) {
        InterceptorRegistration addInterceptor = registry.addInterceptor(getLoginInterceptor());
        
        // 排除配置
        //addInterceptor.excludePathPatterns("/**");
        //addInterceptor.excludePathPatterns("/wx/auth");
        //addInterceptor.excludePathPatterns("/web/**");
        //addInterceptor.excludePathPatterns("/app/**");
        //addInterceptor.excludePathPatterns("/login**");

        // 拦截配置
        //addInterceptor.addPathPatterns("/**");
        addInterceptor.addPathPatterns("/user/**");
    }

}
